package sns.action;

import org.springframework.transaction.annotation.Transactional;

import sns.bean.Impression;
import sns.dao.ImpressionDao;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class DeleteImpressionAction extends ActionSupport {

	// injection
	ImpressionDao impressionDao;
	// pass in
	private Long impressionId;
	private Long visitId;

	// return
	// private Long visitId;

	@Transactional
	public String execute() {

		if (impressionId == null) {
			System.out.println("Impression Id is null");
			return ActionSupport.INPUT;
		}
		Impression impression = impressionDao.getImpressionById(impressionId);
		if (impression != null) {
			impressionDao.delete(impression);
		} else {
			System.out.println("There is no such impression.");
			return ActionSupport.ERROR;
		}

		return ActionSupport.SUCCESS;
	}

	public Long getVisitId() {
		return visitId;
	}

	public void setVisitId(Long visitId) {
		this.visitId = visitId;
	}

	public void setImpressionDao(ImpressionDao impressionDao) {
		this.impressionDao = impressionDao;
	}

	public void setImpressionId(Long impressionId) {
		this.impressionId = impressionId;
	}

}
